import request from "@/utils/request.ts";
import type {UserInter, UserResponseInter} from "@/api/acl/user/type.ts";
import type {ResponseInter} from "@/api/commonInterFace.ts";

enum Api {
    allUser_url = "/admin/acl/user",
    user_url_add = '/admin/acl/user/save',
    user_url_update = '/admin/acl/user/update',

}

export const reqUserList = (page: number, limit: number, username: string) => request.get<string, UserResponseInter>(`${Api.allUser_url}/${page}/${limit}?username=${username}`)

export const reqUserAddOrUpdate = (data: UserInter) => {
    if (data.id) {
        return request.put<string, ResponseInter>(Api.user_url_update, data)
    } else {
        return request.post<string, ResponseInter>(Api.user_url_add, data)
    }
}
